package Work3;

import java.util.ArrayList;
import java.util.Comparator;
import java.util.Iterator;

/*
 *@Student 张策
 */
public class Main {
    public static void main(String[] args) {
        Employee employee1 = new Employee("zcsd",18000,new MyDate(2005,8,2));
        Employee employee2 = new Employee("明",8000,new MyDate(2005,4,3));
        Employee employee3 = new Employee("小刚",9000,new MyDate(2005,2,2));
        ArrayList<Employee> list = new ArrayList<>();
        list.add(employee1);
        list.add(employee2);
        list.add(employee3);
        list.sort(new Comparator<Employee>() {
            @Override
            public int compare(Employee o1, Employee o2) {
                int name=o1.getName().compareTo(o2.getName());
                if(name!=0) {
                    return name;
                }
                return o1.getBirthday().compareTo(o2.getBirthday());
            }
        });
        Iterator<Employee> iterator = list.iterator();
        while (iterator.hasNext()) {
            Employee next = iterator.next();
            System.out.println(next);
        }
    }
}
